package Command;
/**
 * Rudder
 * @author Danny
 *
 */
public class Rudder extends Command {
	@Override
	public void execute() 
	{
		// Check if connection is ok, return if it isnt
		if(!checkConnection())
		{
			return;
		}
		// Rudder, Degree, Checksum
		bt.sendLine("3,"+ getValue() +"," + (3 + getValue()));
		if(getValue() < 10)
		{
			bt.sendLine("3,00"+ getValue() +",00" + (3 + getValue()));
		}else if(getValue() < 100)
		{
			bt.sendLine("3,0"+ getValue() +",0" + (3 + getValue()));
		}else 
		{
			bt.sendLine("3,"+ getValue() +"," + (3 + getValue()));
		}
	}
	/**
	 * getCommandString
	 * @return String - Command
	 */
	public String getCommandString()
	{
		if(getValue() < 10)
		{
			return "3,00"+ getValue() +",00" + (3 + getValue());
		}else if(getValue() < 100)
		{
			return "3,0"+ getValue() +",0" + (3 + getValue());
		}else 
		{
			return "3,"+ getValue() +"," + (3 + getValue());
		}
	}

	@Override
	public void redo() 
	{
		execute();	
	}

	@Override
	public void undo() 
	{}
}
